<?php
class Mivec_Http_Google_Data extends Mivec_Http_Google_Abstract
{
	protected $_url;
	protected $_keyword;
	protected $_method;
	protected $_adapter;
	protected $_response;
	
	static $_queries;
	
	public function __construct($_keyword,$_method='normal')
	{
		self::$_queries = self::$_queries + 1;
		
		Zend_Loader::loadClass('Mivec_Http_Socket');
		
		$this->_url = 'http://www.google.com/search?hl=en&q=';
		$this->_method = $_method;
		self::_init($_keyword);
	}
	
	protected function _init($_keyword)
	{
		switch($this->_method) {
			case 'normal':{
				
				break;
			}
			case 'cache':{
				$this->_url .= "cache:";
				break;
			}
			case 'inurl':{
				$this->_url .= "inurl:";
				break;
			}
			case 'site': {
				$this->_url .= 'site:';
				break;
			}
			case 'link': {
				$this->_url .= 'link:';
				break;
			}
		}
		$this->_keyword .= urlencode($_keyword);
		$this->_url .= $this->_keyword;
	}
	
	public function request()
	{
		$this->_adapter = new Mivec_Http_Socket($this->_url);
		$this->_response = $this->_adapter->request();
		return $this;
	}
	
	public function get()
	{
		return $this->_response->getBody();
	}
}
